import { defineStore } from 'pinia'
import { ref } from 'vue'
export interface ConsultData {
  illnessDesc: string
  illnessTime: number
  consultFlag: number
  pictures: { id: string; url: string }[]
}
const illnessData: ConsultData = {
  illnessDesc: '',
  illnessTime: 1,
  consultFlag: 0,
  pictures: [],
}
export const useConsultStore = defineStore(
  'consult',
  () => {
    const illnessInfo = ref<ConsultData>({ ...illnessData })
    const upateIllnessInfo = (obj: ConsultData) => {
      illnessInfo.value = obj
    }
    //急速问诊
    const type = ref('')
    const setType = (types: string) => {
      type.value = types
    }
    //三甲普通
    const illnessType = ref('')
    const setIllnessType = (type: string) => {
      illnessType.value = type
    }
    //科室id
    const depId = ref('')
    const setDepId = (id: string) => {
      depId.value = id
    }
    //患者id
    const patinentId = ref('')
    const setPatinentId = (value: string) => {
      patinentId.value = value
    }
    // 清空参数
    const clear = () => {
      illnessInfo.value = { ...illnessData }
      type.value = ''
      illnessType.value = ''
      depId.value = ''
      patinentId.value = ''
    }
    return {
      illnessInfo,
      upateIllnessInfo,
      type,
      setType,
      illnessType,
      setIllnessType,
      depId,
      setDepId,
      patinentId,
      setPatinentId,
      clear,
    }
  },
  {
    unistorage: true,
  }
)
